package com.hr.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.hr.entity.ConfigFileThirdKind;
import com.hr.mapper.ConfigFileThirdKindMapper;
import com.hr.service.ConfigFileThirdKindService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import org.springframework.web.bind.annotation.DeleteMapping;

import java.util.List;

@Service
public class ConfigFileThirdKindServiceImpl implements ConfigFileThirdKindService {
    @Autowired
    private ConfigFileThirdKindMapper configFileThirdKindMapper;

    /**
     * 查询三级机构设置列表
     *
     * @return
     */
    @Override
    public List<ConfigFileThirdKind> queryList(ConfigFileThirdKind configFileThirdKind) {
        QueryWrapper<ConfigFileThirdKind> queryWrapper = new QueryWrapper<ConfigFileThirdKind>();
        if (configFileThirdKind.getSecondKindId() != null && !configFileThirdKind.getSecondKindId().isEmpty()) {
            queryWrapper.eq("second_kind_id", configFileThirdKind.getSecondKindId());
        }

        List<ConfigFileThirdKind> list =
                configFileThirdKindMapper.selectList(queryWrapper);
        return list;
    }

    /**
     * 保存/修改
     *
     * @param configFileThirdKind
     * @return
     */
    @Override
    public boolean save(ConfigFileThirdKind configFileThirdKind) {
        int row = 0;
        if (configFileThirdKind.getFtkid() == null) {
            row = configFileThirdKindMapper.insert(configFileThirdKind);
        } else {
            row = configFileThirdKindMapper.updateById(configFileThirdKind);
        }
        return row > 0;
    }

    /**
     * 删除
     *
     * @param ftkid
     * @return
     */
    @Override
    public boolean del(Integer ftkid) {
        int i = configFileThirdKindMapper.deleteById(ftkid);
        return i > 0;
    }

    /**
     * 单值查询
     *
     * @param ftkid
     * @return
     */
    @Override
    public ConfigFileThirdKind queryById(Integer ftkid) {
        ConfigFileThirdKind configFileThirdKind = configFileThirdKindMapper.selectById(ftkid);
        return configFileThirdKind;
    }



}


/**
 * 三级机构设置 的业务
 */

